﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TelnetRouterApplication.Model
{
    public class Route
    {
        private IpModel _network;

        public IpModel Network
        {
            get { return _network; }
            set { _network = value; }
        }
        private IpModel _mask;

        public IpModel Mask
        {
            get { return _mask; }
            set { _mask = value; }
        }
        private IpModel _whereToGo;

        public IpModel WhereToGo
        {
            get { return _whereToGo; }
            set { _whereToGo = value; }
        }

        public Route() : this("", "","") { }

        public Route(string network) : this(network, "", "") { }

        public Route(string network, string mask, string whereToGo)
        {
            Network = new IpModel(network);
            Mask = new IpModel(mask);
            WhereToGo = new IpModel(whereToGo);
        }

        public bool Equals(object obj)
        {
            if (obj is Route)
            {
                Route compareTo = (Route)obj;

                return _network.Equals(compareTo._network) && _mask.Equals(compareTo._mask) && _whereToGo.Equals(compareTo._whereToGo);
            }

            return false;
        }

        public override string ToString()
        {
            if(Mask.Equals(""))
            {
                return Network.ip;
            }
            else
            {
                return Network.ip + "/" + Mask.ip + " via " + WhereToGo.ip;
            }
        }
    }
}
